{% set pypi_name = 'python-openstackclient' %}
{% set upstream_version = upstream_version('5.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Command-line Client
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('python-cinderclient') }}
BuildRequires:  {{ py3('cliff') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('python-glanceclient') }}
BuildRequires:  {{ py3('python-keystoneclient') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('python-novaclient') }}
BuildRequires:  {{ py3('openstacksdk') }}
BuildRequires:  {{ py3('os-client-config') }}
BuildRequires:  {{ py3('osc-lib') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('osprofiler') }}
BuildRequires:  {{ py3('requests') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('setuptools') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('testtools') }}
BuildRequires:  {{ py3('wrapt') }}
BuildArch:      noarch

%description
python-openstackclient is a unified command-line client for the OpenStack APIs.
It is a thin wrapper to the stock python-*client modules that implement the
actual REST API client actions.

%package -n python3-openstackclient
Summary:        OpenStack Command-line Client
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('python-cinderclient') }}
Requires:       {{ py3('cliff') }}
Requires:       {{ py3('python-glanceclient') }}
Requires:       {{ py3('python-heatclient') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('python-keystoneclient') }}
Requires:       {{ py3('python-novaclient') }}
Requires:       {{ py3('openstacksdk') }}
Requires:       {{ py3('osc-lib') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 4.0.0
%endif

%description -n python3-openstackclient
python-openstackclient is a unified command-line client for the OpenStack APIs.
It is a thin wrapper to the stock python-*client modules that implement the
actual REST API client actions.

This package contains the Python 3.x module.

%package -n python-openstackclient-doc
Summary:        Documentation for OpenStack Command-line Client
Group:          Documentation/HTML
# Some clients are commented out, since they have not been built yet
# TODO(jpena): uncomment them to enable their sections in the documentation
BuildRequires:  {{ py3('Sphinx') }}
#BuildRequires:  {{ py3('aodhclient') }}
#BuildRequires:  {{ py3('python-barbicanclient') }}
#BuildRequires:  {{ py3('python-designateclient') }}
#BuildRequires:  {{ py3('python-heatclient') }}
#BuildRequires:  {{ py3('python-ironicclient') }}
#BuildRequires:  {{ py3('python-mistralclient') }}
#BuildRequires:  {{ py3('python-muranoclient') }}
#BuildRequires:  {{ py3('python-neutronclient') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
#BuildRequires:  {{ py3('python-ironic-inspector-client') }}
#BuildRequires:  {{ py3('python-saharaclient') }}
#BuildRequires:  {{ py3('python-zaqarclient') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-openstackclient-doc
python-openstackclient is a unified command-line client for the OpenStack APIs.
It is a thin wrapper to the stock python-*client modules that implement the
actual REST API client actions.
This package contains auto-generated documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
PBR_VERSION={{ upstream_version }} %sphinx_build -b man doc/source doc/build/man
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}
# man page
install -p -D -m 644 doc/build/man/openstack.1 %{buildroot}%{_mandir}/man1/openstack.1

%check
python3 -m stestr.cli run

%files -n python3-openstackclient
%doc README.rst
%license LICENSE
%{python3_sitelib}/openstackclient
%{python3_sitelib}/*.egg-info
%{_bindir}/openstack
%{_mandir}/man1/openstack.1.gz

%files -n python-openstackclient-doc
%license LICENSE
%doc doc/build/html

%changelog
